<html><head><title>CodeNarc Report: Sample Report</title><style type='text/css'>body {
    font-family: Arial, sans-serif;
    margin: 20px 20px 20px 30px;
}

h1, h2, h3 {
    font-weight: bold;
}

h1 {
    width: 400px;
    text-align: center;

    color: white;
    background-color: #557799;
    padding: 10px;

    -moz-box-shadow: 3px 3px 4px #AAA;
    -webkit-box-shadow: 3px 3px 4px #AAA;
    box-shadow: 3px 3px 4px #AAA;

    border-radius: 10px;
    -moz-border-radius: 10px;

    text-shadow: 2px 2px 2px black;
}

h2 {
    font-size: 150%;
    margin-top: 40px;
    padding-top: 5px;
    border-top: 5px solid lightgray;
}

h3 {
    margin-left: 10px;
    margin-top: 30px;
}

a {
    text-decoration: underline;
    color: #D93544;
}

.logo {
    float: right;
}

.metadata {
}

.summary {
    margin-bottom: 20px;
}

.reportInfo {
    font-size: 110%;
}

.allPackages {
    font-weight: bold;
}

.fileHeader {
    font-size: 120%;
    font-weight: bold;
}

.tableHeader {
    font-weight: bold;
}

.number {
    text-align: center;
}

.priority1, .priority2, .priority3 {
    font-weight: bold;
    text-align: center;
    color: #990000;
}

.priority1 {
    background-color: #FFAAAA;
}

.priority2 {
    background-color: #FFCCAA;
}

.priority3 {
    background-color: #FFEEAA;
}

.ruleName {
    font-weight: bold;
    color: black;
    text-align: left;
}

.violationInfo {
    margin-bottom: 2px;
    margin-top: 2px;
}

.violationInfoPrefix {
    font-size: 60%;
    width: 30px;
    color: #a9a9a9;
    padding-right: 4px;
}

.sourceCode {
    font-family: Arial, sans-serif;
    font-size: 80%;
    color: #444444;
}

.violationMessage {
    font-style: italic;
    font-size: 80%;
    color: black;
}

.ruleDescriptions {
    font-size: 85%;
}

.version {
    margin-top: 1px;
}

table {
    border: 2px solid gray;
    border-collapse: collapse;

    -moz-box-shadow: 3px 3px 4px #AAA;
    -webkit-box-shadow: 3px 3px 4px #AAA;
    box-shadow: 3px 3px 4px #AAA;
}

td, th {
    border: 1px solid #D3D3D3;
    padding: 4px 20px 4px 20px;
}

th {
    text-shadow: 2px 2px 2px white;
}

th {
    border-bottom: 1px solid gray;
    background-color: #DDDDFF;
}

em, .em {
    font-weight: bold;
}</style></head><body><img class='logo' src='http://codenarc.sourceforge.net/images/codenarc-logo.png' alt='CodeNarc' align='right'/><h1>CodeNarc Report</h1><div class='metadata'><table><tr><td class='em'>Report title:</td><td>Sample Report</td></tr><tr><td class='em'>Date:</td><td>12/08/2011 02:01:37</td></tr><tr><td class='em'>Generated with:</td><td><a href='http://www.codenarc.org'>CodeNarc v0.15</a></td></tr></table></div><div class='summary'><h2>Summary by Package</h2><table><tr class='tableHeader'><th>Package</th><th>Total Files</th><th>Files with Violations</th><th>Priority 1</th><th>Priority 2</th><th>Priority 3</th></tr><tr><td class='allPackages'>All Packages</td><td class='number'>0</td><td class='number'>-</td><td class='priority1'>-</td><td class='priority2'>-</td><td class='priority3'>-</td></tr></table></div><div class='summary'><h2>Rule Descriptions</h2><table border='1'><tr class='tableHeader'><th class='ruleDescriptions'>#</th><th class='ruleDescriptions'>Rule Name</th><th class='ruleDescriptions'>Description</th></tr><tr class='ruleDescriptions'><a name='AddEmptyString'/><td>1</td><td class='ruleName priority2'>AddEmptyString</td><td>Finds empty string literals which are being added. This is an inefficient way to convert any type to a String.</td></tr><tr class='ruleDescriptions'><a name='AssignCollectionSort'/><td>2</td><td class='ruleName priority2'>AssignCollectionSort</td><td>The Collections.sort() method mutates the list and returns the list as a value. If you are assigning the result of sort() to a variable, then you probably don't realize that you're also modifying the original list as well. This is frequently the cause of subtle bugs.</td></tr><tr class='ruleDescriptions'><a name='AssignCollectionUnique'/><td>3</td><td class='ruleName priority2'>AssignCollectionUnique</td><td>The Collections.unique() method mutates the list and returns the list as a value. If you are assigning the result of unique() to a variable, then you probably don't realize that you're also modifying the original list as well. This is frequently the cause of subtle bugs.</td></tr><tr class='ruleDescriptions'><a name='AssignmentInConditional'/><td>4</td><td class='ruleName priority2'>AssignmentInConditional</td><td>An assignment operator (=) was used in a conditional test. This is usually a typo, and the comparison operator (==) was intended.</td></tr><tr class='ruleDescriptions'><a name='BigDecimalInstantiation'/><td>5</td><td class='ruleName priority2'>BigDecimalInstantiation</td><td>Checks for calls to the <em>BigDecimal</em> constructors that take a <em>double</em> parameter, which may result in an unexpected <em>BigDecimal</em> value.</td></tr><tr class='ruleDescriptions'><a name='BitwiseOperatorInConditional'/><td>6</td><td class='ruleName priority2'>BitwiseOperatorInConditional</td><td>Checks for bitwise operations in conditionals, if you need to do a bitwise operation then it is best practive to extract a temp variable.</td></tr><tr class='ruleDescriptions'><a name='BooleanGetBoolean'/><td>7</td><td class='ruleName priority2'>BooleanGetBoolean</td><td>This rule catches usages of java.lang.Boolean.getBoolean(String) which reads a boolean from the System properties. It is often mistakenly used to attempt to read user input or parse a String into a boolean. It is a poor piece of API to use; replace it with System.properties['prop'].</td></tr><tr class='ruleDescriptions'><a name='BooleanMethodReturnsNull'/><td>8</td><td class='ruleName priority2'>BooleanMethodReturnsNull</td><td>Method with Boolean return type returns explicit null. A method that returns either Boolean.TRUE, Boolean.FALSE or null is an accident waiting to happen. This method can be invoked as though it returned a value of type boolean, and the compiler will insert automatic unboxing of the Boolean value. If a null value is returned, this will result in a NullPointerException.</td></tr><tr class='ruleDescriptions'><a name='BrokenOddnessCheck'/><td>9</td><td class='ruleName priority2'>BrokenOddnessCheck</td><td>The code uses x % 2 == 1 to check to see if a value is odd, but this won't work for negative numbers (e.g., (-5) % 2 == -1). If this code is intending to check for oddness, consider using x &amp; 1 == 1, or x % 2 != 0.</td></tr><tr class='ruleDescriptions'><a name='CatchArrayIndexOutOfBoundsException'/><td>10</td><td class='ruleName priority2'>CatchArrayIndexOutOfBoundsException</td><td>Check the size of the array before accessing an array element rather than catching <em>ArrayIndexOutOfBoundsException</em>.</td></tr><tr class='ruleDescriptions'><a name='CatchError'/><td>11</td><td class='ruleName priority2'>CatchError</td><td>Catching <em>Error</em> is dangerous; it can catch exceptions such as <em>ThreadDeath</em> and <em>OutOfMemoryError</em>.</td></tr><tr class='ruleDescriptions'><a name='CatchException'/><td>12</td><td class='ruleName priority2'>CatchException</td><td>Catching <em>Exception</em> is often too broad or general. It should usually be restricted to framework or infrastructure code, rather than application code.</td></tr><tr class='ruleDescriptions'><a name='CatchIllegalMonitorStateException'/><td>13</td><td class='ruleName priority2'>CatchIllegalMonitorStateException</td><td>Dubious catching of IllegalMonitorStateException. IllegalMonitorStateException is generally only thrown in case of a design flaw in your code (calling wait or notify on an object you do not hold a lock on).</td></tr><tr class='ruleDescriptions'><a name='CatchIndexOutOfBoundsException'/><td>14</td><td class='ruleName priority2'>CatchIndexOutOfBoundsException</td><td>Check that an index is valid before accessing an indexed element rather than catching <em>IndexOutOfBoundsException</em>.</td></tr><tr class='ruleDescriptions'><a name='CatchNullPointerException'/><td>15</td><td class='ruleName priority2'>CatchNullPointerException</td><td>Catching <em>NullPointerException</em> is never appropriate. It should be avoided in the first place with proper null checking, and it can mask underlying errors.</td></tr><tr class='ruleDescriptions'><a name='CatchRuntimeException'/><td>16</td><td class='ruleName priority2'>CatchRuntimeException</td><td>Catching <em>RuntimeException</em> is often too broad or general. It should usually be restricted to framework or infrastructure code, rather than application code.</td></tr><tr class='ruleDescriptions'><a name='CatchThrowable'/><td>17</td><td class='ruleName priority2'>CatchThrowable</td><td>Catching <em>Throwable</em> is dangerous; it can catch exceptions such as <em>ThreadDeath</em> and <em>OutOfMemoryError</em>.</td></tr><tr class='ruleDescriptions'><a name='ClassForName'/><td>18</td><td class='ruleName priority2'>ClassForName</td><td>Using Class.forName(...) is a common way to add dynamic behavior to a system. However, using this method can cause resource leaks because the classes can be pinned in memory for long periods of time.</td></tr><tr class='ruleDescriptions'><a name='CloneableWithoutClone'/><td>19</td><td class='ruleName priority2'>CloneableWithoutClone</td><td>A class that implements <em>java.lang.Cloneable</em> should define a <em>clone()</em> method.</td></tr><tr class='ruleDescriptions'><a name='ClosureAsLastMethodParameter'/><td>20</td><td class='ruleName priority3'>ClosureAsLastMethodParameter</td><td>If a method is called and the last parameter is an inline closure then it can be declared outside of the method call brackets.</td></tr><tr class='ruleDescriptions'><a name='CompareToWithoutComparable'/><td>21</td><td class='ruleName priority2'>CompareToWithoutComparable</td><td>If you implement a compareTo method then you should also implement the Comparable interface. If you don't then you could possibly get an exception if the Groovy == operator is invoked on your object. This is an issue fixed in Groovy 1.8 but present in previous versions.</td></tr><tr class='ruleDescriptions'><a name='ComparisonOfTwoConstants'/><td>22</td><td class='ruleName priority2'>ComparisonOfTwoConstants</td><td>Checks for expressions where a comparison operator or <em>equals()</em> or <em>compareTo()</em> is used to compare two constants to each other or two literals that contain only constant values., e.g.: <em>23 == 67, Boolean.FALSE != false, 0.17 &lt;= 0.99, "abc" &gt; "ddd", [a:1] &lt;=&gt; [a:2], [1,2].equals([3,4]) or [a:false, b:true].compareTo(['a':34.5, b:Boolean.TRUE]</em>.</td></tr><tr class='ruleDescriptions'><a name='ComparisonWithSelf'/><td>23</td><td class='ruleName priority2'>ComparisonWithSelf</td><td>Checks for expressions where a comparison operator or <em>equals()</em> or <em>compareTo()</em> is used to compare a variable to itself, e.g.: <em>x == x, x != x, x &lt;=&gt; x, x &lt; x, x =&gt;= x, x.equals(x) or x.compareTo(x)</em>, where <em>x</em> is a variable.</td></tr><tr class='ruleDescriptions'><a name='ConfusingClassNamedException'/><td>24</td><td class='ruleName priority2'>ConfusingClassNamedException</td><td>This class is not derived from another exception, but ends with 'Exception'. This will be confusing to users of this class.</td></tr><tr class='ruleDescriptions'><a name='ConfusingTernary'/><td>25</td><td class='ruleName priority2'>ConfusingTernary</td><td>In a ternary expression avoid negation in the test. For example, rephrase: "(x != y) ? diff : same" as: "(x == y) ? same : diff". Consistent use of this rule makes the code easier to read. Also, this resolves trivial ordering problems, such as "does the error case go first?" or "does the common case go first?".</td></tr><tr class='ruleDescriptions'><a name='ConsecutiveLiteralAppends'/><td>26</td><td class='ruleName priority2'>ConsecutiveLiteralAppends</td><td>Violations occur when method calls to append(Object) are chained together with literals as parameters. The chained calls can be joined into one invocation.</td></tr><tr class='ruleDescriptions'><a name='ConsecutiveStringConcatenation'/><td>27</td><td class='ruleName priority3'>ConsecutiveStringConcatenation</td><td>Catches concatenation of two string literals on the same line. These can safely by joined.</td></tr><tr class='ruleDescriptions'><a name='ConstantIfExpression'/><td>28</td><td class='ruleName priority2'>ConstantIfExpression</td><td>Checks for <em>if</em> statements with a constant value for the if expression, such as <em>true</em>, <em>false</em>, <em>null</em>, or a literal constant value.</td></tr><tr class='ruleDescriptions'><a name='ConstantTernaryExpression'/><td>29</td><td class='ruleName priority2'>ConstantTernaryExpression</td><td>Checks for ternary expressions with a constant value for the boolean expression, such as <em>true</em>, <em>false</em>, <em>null</em>, or a literal constant value.</td></tr><tr class='ruleDescriptions'><a name='DeadCode'/><td>30</td><td class='ruleName priority2'>DeadCode</td><td>Dead code appears after a return statement or an exception is thrown. If code appears after one of these statements then it will never be executed and can be safely deleted.</td></tr><tr class='ruleDescriptions'><a name='DoubleNegative'/><td>31</td><td class='ruleName priority2'>DoubleNegative</td><td>There is no point in using a double negative, it is always positive. For instance <em>!!x</em> can always be simplified to x. And <em>!(!x)</em> can as well.</td></tr><tr class='ruleDescriptions'><a name='DuplicateCaseStatement'/><td>32</td><td class='ruleName priority2'>DuplicateCaseStatement</td><td>Check for duplicate <em>case</em> statements in a <em>switch</em> block, such as two equal integers or strings.</td></tr><tr class='ruleDescriptions'><a name='DuplicateImport'/><td>33</td><td class='ruleName priority3'>DuplicateImport</td><td>Duplicate import statements are unnecessary.</td></tr><tr class='ruleDescriptions'><a name='DuplicateMapKey'/><td>34</td><td class='ruleName priority2'>DuplicateMapKey</td><td>A map literal is created with duplicated key. The map entry will be overwritten.</td></tr><tr class='ruleDescriptions'><a name='DuplicateSetValue'/><td>35</td><td class='ruleName priority2'>DuplicateSetValue</td><td>A Set literal is created with duplicate constant value. A set cannot contain two elements with the same value.</td></tr><tr class='ruleDescriptions'><a name='EmptyCatchBlock'/><td>36</td><td class='ruleName priority2'>EmptyCatchBlock</td><td>In most cases, exceptions should not be caught and ignored (swallowed).</td></tr><tr class='ruleDescriptions'><a name='EmptyElseBlock'/><td>37</td><td class='ruleName priority2'>EmptyElseBlock</td><td>Empty <em>else</em> blocks are confusing and serve no purpose.</td></tr><tr class='ruleDescriptions'><a name='EmptyFinallyBlock'/><td>38</td><td class='ruleName priority2'>EmptyFinallyBlock</td><td>Empty <em>finally</em> blocks are confusing and serve no purpose.</td></tr><tr class='ruleDescriptions'><a name='EmptyForStatement'/><td>39</td><td class='ruleName priority2'>EmptyForStatement</td><td>Empty <em>for</em> statements are confusing and serve no purpose.</td></tr><tr class='ruleDescriptions'><a name='EmptyIfStatement'/><td>40</td><td class='ruleName priority2'>EmptyIfStatement</td><td>Empty <em>if</em> statements are confusing and serve no purpose.</td></tr><tr class='ruleDescriptions'><a name='EmptyInstanceInitializer'/><td>41</td><td class='ruleName priority2'>EmptyInstanceInitializer</td><td>An empty class instance initializer was found. It is safe to remove it.</td></tr><tr class='ruleDescriptions'><a name='EmptyMethod'/><td>42</td><td class='ruleName priority2'>EmptyMethod</td><td>A method was found without an implementation. If the method is overriding or implementing a parent method, then mark it with the @Override annotation.</td></tr><tr class='ruleDescriptions'><a name='EmptyStaticInitializer'/><td>43</td><td class='ruleName priority2'>EmptyStaticInitializer</td><td>An empty static initializer was found. It is safe to remove it.</td></tr><tr class='ruleDescriptions'><a name='EmptySwitchStatement'/><td>44</td><td class='ruleName priority2'>EmptySwitchStatement</td><td>Empty <em>switch</em> statements are confusing and serve no purpose.</td></tr><tr class='ruleDescriptions'><a name='EmptySynchronizedStatement'/><td>45</td><td class='ruleName priority2'>EmptySynchronizedStatement</td><td>Empty <em>synchronized</em> statements are confusing and serve no purpose.</td></tr><tr class='ruleDescriptions'><a name='EmptyTryBlock'/><td>46</td><td class='ruleName priority2'>EmptyTryBlock</td><td>Empty <em>try</em> blocks are confusing and serve no purpose.</td></tr><tr class='ruleDescriptions'><a name='EmptyWhileStatement'/><td>47</td><td class='ruleName priority2'>EmptyWhileStatement</td><td>Empty <em>while</em> statements are confusing and serve no purpose.</td></tr><tr class='ruleDescriptions'><a name='EqualsAndHashCode'/><td>48</td><td class='ruleName priority2'>EqualsAndHashCode</td><td>If either the <em>boolean equals(Object)</em> or the <em>int hashCode()</em> methods are overridden within a class, then both must be overridden.</td></tr><tr class='ruleDescriptions'><a name='EqualsOverloaded'/><td>49</td><td class='ruleName priority2'>EqualsOverloaded</td><td>The class has an equals method, but the parameter of the method is not of type Object. It is not overriding equals but instead overloading it.</td></tr><tr class='ruleDescriptions'><a name='ExceptionExtendsError'/><td>50</td><td class='ruleName priority2'>ExceptionExtendsError</td><td>Errors are system exceptions. Do not extend them.</td></tr><tr class='ruleDescriptions'><a name='ExplicitArrayListInstantiation'/><td>51</td><td class='ruleName priority2'>ExplicitArrayListInstantiation</td><td>This rule checks for the explicit instantiation of an <em>ArrayList</em> using the no-arg constructor. In Groovy, it is best to write <em>new ArrayList()</em> as <em>[]</em>, which creates the same object.</td></tr><tr class='ruleDescriptions'><a name='ExplicitCallToAndMethod'/><td>52</td><td class='ruleName priority2'>ExplicitCallToAndMethod</td><td>This rule detects when the <em>and(Object)</em> method is called directly in code instead of using the &amp; operator. A groovier way to express this: <em>a.and(b)</em> is this: <em>a &amp; b</em></td></tr><tr class='ruleDescriptions'><a name='ExplicitCallToCompareToMethod'/><td>53</td><td class='ruleName priority2'>ExplicitCallToCompareToMethod</td><td>This rule detects when the <em>compareTo(Object)</em> method is called directly in code instead of using the &lt;=&gt;, &gt;, &gt;=, &lt;, and &lt;= operators. A groovier way to express this: <em>a.compareTo(b)</em> is this: <em>a &lt;=&gt; b</em>, or using the other operators.</td></tr><tr class='ruleDescriptions'><a name='ExplicitCallToDivMethod'/><td>54</td><td class='ruleName priority2'>ExplicitCallToDivMethod</td><td>This rule detects when the <em>div(Object)</em> method is called directly in code instead of using the / operator. A groovier way to express this: <em>a.div(b)</em> is this: <em>a / b</em></td></tr><tr class='ruleDescriptions'><a name='ExplicitCallToEqualsMethod'/><td>55</td><td class='ruleName priority2'>ExplicitCallToEqualsMethod</td><td>This rule detects when the <em>equals(Object)</em> method is called directly in code instead of using the == or != operator. A groovier way to express this: <em>a.equals(b)</em> is this: <em>a == b</em> and a groovier way to express : <em>!a.equals(b)</em> is : <em>a != b</em></td></tr><tr class='ruleDescriptions'><a name='ExplicitCallToGetAtMethod'/><td>56</td><td class='ruleName priority2'>ExplicitCallToGetAtMethod</td><td>This rule detects when the <em>getAt(Object)</em> method is called directly in code instead of using the [] index operator. A groovier way to express this: <em>a.getAt(b)</em> is this: <em>a[b]</em></td></tr><tr class='ruleDescriptions'><a name='ExplicitCallToLeftShiftMethod'/><td>57</td><td class='ruleName priority2'>ExplicitCallToLeftShiftMethod</td><td>This rule detects when the <em>leftShift(Object)</em> method is called directly in code instead of using the &lt;&lt; operator. A groovier way to express this: <em>a.leftShift(b)</em> is this: <em>a &lt;&lt; b</em></td></tr><tr class='ruleDescriptions'><a name='ExplicitCallToMinusMethod'/><td>58</td><td class='ruleName priority2'>ExplicitCallToMinusMethod</td><td>This rule detects when the <em>minus(Object)</em> method is called directly in code instead of using the - operator. A groovier way to express this: <em>a.minus(b)</em> is this: <em>a - b</em></td></tr><tr class='ruleDescriptions'><a name='ExplicitCallToModMethod'/><td>59</td><td class='ruleName priority2'>ExplicitCallToModMethod</td><td>This rule detects when the <em>mod(Object)</em> method is called directly in code instead of using the % operator. A groovier way to express this: <em>a.mod(b)</em> is this: <em>a % b</em></td></tr><tr class='ruleDescriptions'><a name='ExplicitCallToMultiplyMethod'/><td>60</td><td class='ruleName priority2'>ExplicitCallToMultiplyMethod</td><td>This rule detects when the <em>minus(Object)</em> method is called directly in code instead of using the * operator. A groovier way to express this: <em>a.multiply(b)</em> is this: <em>a * b</em></td></tr><tr class='ruleDescriptions'><a name='ExplicitCallToOrMethod'/><td>61</td><td class='ruleName priority2'>ExplicitCallToOrMethod</td><td>This rule detects when the <em>or(Object)</em> method is called directly in code instead of using the | operator. A groovier way to express this: <em>a.or(b)</em> is this: <em>a | b</em></td></tr><tr class='ruleDescriptions'><a name='ExplicitCallToPlusMethod'/><td>62</td><td class='ruleName priority2'>ExplicitCallToPlusMethod</td><td>This rule detects when the <em>plus(Object)</em> method is called directly in code instead of using the + operator. A groovier way to express this: <em>a.plus(b)</em> is this: <em>a + b</em></td></tr><tr class='ruleDescriptions'><a name='ExplicitCallToPowerMethod'/><td>63</td><td class='ruleName priority2'>ExplicitCallToPowerMethod</td><td>This rule detects when the <em>power(Object)</em> method is called directly in code instead of using the ** operator. A groovier way to express this: <em>a.power(b)</em> is this: <em>a ** b</em></td></tr><tr class='ruleDescriptions'><a name='ExplicitCallToRightShiftMethod'/><td>64</td><td class='ruleName priority2'>ExplicitCallToRightShiftMethod</td><td>This rule detects when the <em>rightShift(Object)</em> method is called directly in code instead of using the >> operator. A groovier way to express this: <em>a.rightShift(b)</em> is this: <em>a >> b</em></td></tr><tr class='ruleDescriptions'><a name='ExplicitCallToXorMethod'/><td>65</td><td class='ruleName priority2'>ExplicitCallToXorMethod</td><td>This rule detects when the <em>xor(Object)</em> method is called directly in code instead of using the ^ operator. A groovier way to express this: <em>a.xor(b)</em> is this: <em>a ^ b</em></td></tr><tr class='ruleDescriptions'><a name='ExplicitGarbageCollection'/><td>66</td><td class='ruleName priority2'>ExplicitGarbageCollection</td><td>Calls to System.gc(), Runtime.getRuntime().gc(), and System.runFinalization() are not advised. Code should have the same behavior whether the garbage collection is disabled using the option -Xdisableexplicitgc or not. Moreover, "modern" jvms do a very good job handling garbage collections. If memory usage issues unrelated to memory leaks develop within an application, it should be dealt with JVM options rather than within the code itself.</td></tr><tr class='ruleDescriptions'><a name='ExplicitHashMapInstantiation'/><td>67</td><td class='ruleName priority2'>ExplicitHashMapInstantiation</td><td>This rule checks for the explicit instantiation of a <em>HashMap</em> using the no-arg constructor. In Groovy, it is best to write <em>new HashMap()</em> as <em>[:]</em>, which creates the same object.</td></tr><tr class='ruleDescriptions'><a name='ExplicitHashSetInstantiation'/><td>68</td><td class='ruleName priority2'>ExplicitHashSetInstantiation</td><td>This rule checks for the explicit instantiation of a <em>HashSet</em> using the no-arg constructor. In Groovy, it is best to write <em>new HashSet()</em> as <em>[] as Set</em>, which creates the same object.</td></tr><tr class='ruleDescriptions'><a name='ExplicitLinkedHashMapInstantiation'/><td>69</td><td class='ruleName priority2'>ExplicitLinkedHashMapInstantiation</td><td>This rule checks for the explicit instantiation of a <em>LinkedHashMap</em> using the no-arg constructor. In Groovy, it is best to write <em>new LinkedHashMap()</em> as <em>[:]</em>, which creates the same object.</td></tr><tr class='ruleDescriptions'><a name='ExplicitLinkedListInstantiation'/><td>70</td><td class='ruleName priority2'>ExplicitLinkedListInstantiation</td><td>This rule checks for the explicit instantiation of a <em>LinkedList</em> using the no-arg constructor. In Groovy, it is best to write <em>new LinkedList()</em> as <em>[] as Queue</em>, which creates the same object.</td></tr><tr class='ruleDescriptions'><a name='ExplicitStackInstantiation'/><td>71</td><td class='ruleName priority2'>ExplicitStackInstantiation</td><td>This rule checks for the explicit instantiation of a <em>Stack</em> using the no-arg constructor. In Groovy, it is best to write <em>new Stack()</em> as <em>[] as Stack</em>, which creates the same object.</td></tr><tr class='ruleDescriptions'><a name='ExplicitTreeSetInstantiation'/><td>72</td><td class='ruleName priority2'>ExplicitTreeSetInstantiation</td><td>This rule checks for the explicit instantiation of a <em>TreeSet</em> using the no-arg constructor. In Groovy, it is best to write <em>new TreeSet()</em> as <em>[] as SortedSet</em>, which creates the same object.</td></tr><tr class='ruleDescriptions'><a name='ForLoopShouldBeWhileLoop'/><td>73</td><td class='ruleName priority3'>ForLoopShouldBeWhileLoop</td><td>A for loop without an init and update statement can be simplified to a while loop.</td></tr><tr class='ruleDescriptions'><a name='GStringAsMapKey'/><td>74</td><td class='ruleName priority2'>GStringAsMapKey</td><td>A GString should not be used as a map key since its hashcode is not guaranteed to be stable. Consider calling <em>key.toString()</em>.</td></tr><tr class='ruleDescriptions'><a name='GrailsDomainHasEquals'/><td>75</td><td class='ruleName priority2'>GrailsDomainHasEquals</td><td>Checks that Grails domain classes redefine equals().</td></tr><tr class='ruleDescriptions'><a name='GrailsDomainHasToString'/><td>76</td><td class='ruleName priority2'>GrailsDomainHasToString</td><td>Checks that Grails domain classes redefine toString()</td></tr><tr class='ruleDescriptions'><a name='GrailsPublicControllerMethod'/><td>77</td><td class='ruleName priority2'>GrailsPublicControllerMethod</td><td>Checks for <em>public</em> methods on Grails controller classes. Static methods are ignored.</td></tr><tr class='ruleDescriptions'><a name='GrailsServletContextReference'/><td>78</td><td class='ruleName priority2'>GrailsServletContextReference</td><td>Checks for references to the <em>servletContext</em> object from within Grails controller and taglib classes.</td></tr><tr class='ruleDescriptions'><a name='GrailsStatelessService'/><td>79</td><td class='ruleName priority2'>GrailsStatelessService</td><td>Checks for fields on Grails service classes. Grails service classes are singletons, by default, and so they should be reentrant and typically stateless. The <em>ignoreFieldNames</em> property (dataSource,scope,sessionFactory,transactional,*Service) specifies one or more field names that should be ignored. The <em>ignoreFieldTypes</em> property (null) specifies one or more field type names that should be ignored. Both can optionally contain wildcard characters ('*' or '?').</td></tr><tr class='ruleDescriptions'><a name='GroovyLangImmutable'/><td>80</td><td class='ruleName priority2'>GroovyLangImmutable</td><td>The groovy.lang.Immutable annotation has been deprecated and replaced by groovy.transform.Immutable. Do not use the Immutable in groovy.lang.</td></tr><tr class='ruleDescriptions'><a name='HardCodedWindowsFileSeparator'/><td>81</td><td class='ruleName priority2'>HardCodedWindowsFileSeparator</td><td>This rule finds usages of a Windows file separator within the constructor call of a File object. It is better to use the Unix file separator or use the File.separator constant.</td></tr><tr class='ruleDescriptions'><a name='HardcodedWindowsRootDirectory'/><td>82</td><td class='ruleName priority2'>HardcodedWindowsRootDirectory</td><td>This rule find cases where a File object is constructed with a windows-based path. This is not portable, and using the File.listRoots() method is a better alternative.</td></tr><tr class='ruleDescriptions'><a name='ImportFromSamePackage'/><td>83</td><td class='ruleName priority3'>ImportFromSamePackage</td><td>An import of a class that is within the same package is unnecessary.</td></tr><tr class='ruleDescriptions'><a name='ImportFromSunPackages'/><td>84</td><td class='ruleName priority2'>ImportFromSunPackages</td><td>Avoid importing anything from the 'sun.*' packages. These packages are not portable and are likely to change.</td></tr><tr class='ruleDescriptions'><a name='IntegerGetInteger'/><td>85</td><td class='ruleName priority2'>IntegerGetInteger</td><td>This rule catches usages of java.lang.Integer.getInteger(String, ...) which reads an Integer from the System properties. It is often mistakenly used to attempt to read user input or parse a String into an Integer. It is a poor piece of API to use; replace it with System.properties['prop'].</td></tr><tr class='ruleDescriptions'><a name='InvertedIfElse'/><td>86</td><td class='ruleName priority2'>InvertedIfElse</td><td>An inverted if-else statement is one in which there is a single <em>if</em> statement with a single <em>else</em> branch and the boolean test of the if is negated. For instance <em>if (!x) false else true</em>. It is usually clearer to write this as <em>if (x) true else false</em>.</td></tr><tr class='ruleDescriptions'><a name='MisorderedStaticImports'/><td>87</td><td class='ruleName priority3'>MisorderedStaticImports</td><td>Static imports should never be declared after nonstatic imports.</td></tr><tr class='ruleDescriptions'><a name='MissingNewInThrowStatement'/><td>88</td><td class='ruleName priority2'>MissingNewInThrowStatement</td><td>A common Groovy mistake when throwing exceptions is to forget the new keyword. For instance, "throw RuntimeException()" instead of "throw new RuntimeException()". If the error path is not unit tested then the production system will throw a Method Missing exception and hide the root cause. This rule finds constructs like "throw RuntimeException()" that look like a new keyword was meant to be used but forgotten.</td></tr><tr class='ruleDescriptions'><a name='RandomDoubleCoercedToZero'/><td>89</td><td class='ruleName priority2'>RandomDoubleCoercedToZero</td><td>The Math.random() method returns a double result greater than or equal to 0.0 and less than 1.0. If you coerce this result into an Integer or int, then it is coerced to zero. Casting the result to int, or assigning it to an int field is probably a bug.</td></tr><tr class='ruleDescriptions'><a name='RemoveAllOnSelf'/><td>90</td><td class='ruleName priority2'>RemoveAllOnSelf</td><td>Don't use <em>removeAll</em> to clear a collection. If you want to remove all elements from a collection c, use c.clear, not c.removeAll(c). Calling <em>c.removeAll(c)</em> to clear a collection is less clear, susceptible to errors from typos, less efficient and for some collections, might throw a <em>ConcurrentModificationException</em>.</td></tr><tr class='ruleDescriptions'><a name='ReturnFromFinallyBlock'/><td>91</td><td class='ruleName priority2'>ReturnFromFinallyBlock</td><td>Returning from a <em>finally</em> block is confusing and can hide the original exception.</td></tr><tr class='ruleDescriptions'><a name='ReturnNullFromCatchBlock'/><td>92</td><td class='ruleName priority2'>ReturnNullFromCatchBlock</td><td>Returning <em>null</em> from a catch block often masks errors and requires the client to handle error codes. In some coding styles this is discouraged.</td></tr><tr class='ruleDescriptions'><a name='ReturnsNullInsteadOfEmptyArray'/><td>93</td><td class='ruleName priority2'>ReturnsNullInsteadOfEmptyArray</td><td>Consider returning a zero length array rather than null. It is often a better design to return a length zero array rather than a null reference to indicate that there are no results (i.e., an empty list of results). This way, no explicit check for null is needed by clients of the method.</td></tr><tr class='ruleDescriptions'><a name='ReturnsNullInsteadOfEmptyCollection'/><td>94</td><td class='ruleName priority2'>ReturnsNullInsteadOfEmptyCollection</td><td>Consider returning a zero length collection rather than null. It is often a better design to return a length zero collection rather than a null reference to indicate that there are no results (i.e., an empty list of results). This way, no explicit check for null is needed by clients of the method.</td></tr><tr class='ruleDescriptions'><a name='SimpleDateFormatMissingLocale'/><td>95</td><td class='ruleName priority2'>SimpleDateFormatMissingLocale</td><td>Be sure to specify a Locale when creating a new instance of SimpleDateFormat; the class is locale-sensitive. If you instantiate SimpleDateFormat without a Locale parameter, it will format the date and time according to the default Locale. Both the pattern and the Locale determine the format. For the same pattern, SimpleDateFormat may format a date and time differently if the Locale varies.</td></tr><tr class='ruleDescriptions'><a name='SwallowThreadDeath'/><td>96</td><td class='ruleName priority2'>SwallowThreadDeath</td><td>Checks for code that catches ThreadDeath without re-throwing it.</td></tr><tr class='ruleDescriptions'><a name='ThrowError'/><td>97</td><td class='ruleName priority2'>ThrowError</td><td>Checks for throwing an instance of <em>java.lang.Error</em>.</td></tr><tr class='ruleDescriptions'><a name='ThrowException'/><td>98</td><td class='ruleName priority2'>ThrowException</td><td>Checks for throwing an instance of <em>java.lang.Exception</em>.</td></tr><tr class='ruleDescriptions'><a name='ThrowExceptionFromFinallyBlock'/><td>99</td><td class='ruleName priority2'>ThrowExceptionFromFinallyBlock</td><td>Throwing an exception from a <em>finally</em> block is confusing and can hide the original exception.</td></tr><tr class='ruleDescriptions'><a name='ThrowNullPointerException'/><td>100</td><td class='ruleName priority2'>ThrowNullPointerException</td><td>Checks for throwing an instance of <em>java.lang.NullPointerException</em>.</td></tr><tr class='ruleDescriptions'><a name='ThrowRuntimeException'/><td>101</td><td class='ruleName priority2'>ThrowRuntimeException</td><td>Checks for throwing an instance of <em>java.lang.RuntimeException</em>.</td></tr><tr class='ruleDescriptions'><a name='ThrowThrowable'/><td>102</td><td class='ruleName priority2'>ThrowThrowable</td><td>Checks for throwing an instance of <em>java.lang.Throwable</em>.</td></tr><tr class='ruleDescriptions'><a name='UnnecessaryGroovyImport'/><td>103</td><td class='ruleName priority3'>UnnecessaryGroovyImport</td><td>A Groovy file does not need to include an import for classes from <em>java.lang</em>, <em>java.util</em>, <em>java.io</em>, <em>java.net</em>, <em>groovy.lang</em> and <em>groovy.util</em>, as well as the classes <em>java.math.BigDecimal</em> and <em>java.math.BigInteger</em>.</td></tr><tr class='ruleDescriptions'><a name='UnusedArray'/><td>104</td><td class='ruleName priority2'>UnusedArray</td><td>Checks for array allocations that are not assigned or used, unless it is the last statement within a block.</td></tr><tr class='ruleDescriptions'><a name='UnusedImport'/><td>105</td><td class='ruleName priority3'>UnusedImport</td><td>Imports for a class that is never referenced within the source file is unnecessary.</td></tr><tr class='ruleDescriptions'><a name='UnusedObject'/><td>106</td><td class='ruleName priority2'>UnusedObject</td><td>Checks for object allocations that are not assigned or used, unless it is the last statement within a block</td></tr><tr class='ruleDescriptions'><a name='UnusedPrivateField'/><td>107</td><td class='ruleName priority2'>UnusedPrivateField</td><td>Checks for private fields that are not referenced within the same class.</td></tr><tr class='ruleDescriptions'><a name='UnusedPrivateMethod'/><td>108</td><td class='ruleName priority2'>UnusedPrivateMethod</td><td>Checks for private methods that are not referenced within the same class.</td></tr><tr class='ruleDescriptions'><a name='UnusedPrivateMethodParameter'/><td>109</td><td class='ruleName priority2'>UnusedPrivateMethodParameter</td><td>Checks for parameters to private methods that are not referenced within the method body.</td></tr><tr class='ruleDescriptions'><a name='UnusedVariable'/><td>110</td><td class='ruleName priority2'>UnusedVariable</td><td>Checks for variables that are never referenced.</td></tr></table></div></body></html>